#pragma once
#include "GameState.h"
#include "MainMenuState.h"
#include "Game.h"
#include "BaseCharacter.h"
#include "BitmapFont.h"
#include "BaseMessage.h"
#include "MessagingSystem.h"
#include "TileManager.h"
#include "Animation.h"
#include "AnimationManager.h"
#include "Archer.h"
#include "Knight.h"
#include "Rogue.h"
#include "Wizard.h"
#include "BlackKnight.h"
#include "Item.h"
#include "WeatherSystem.h"

// Wrappers
#include "SGD Wrappers\CSGD_XAudio2.h"
#include "SGD Wrappers\CSGD_TextureManager.h"

// Unicode 
#include <string>
#if defined UNICODE || _UNICODE
	typedef std::wstring STRING;
#else
	typedef std::string		STRING;
#endif

using namespace std;

class TutorialPlayState : public GameState
{
private:
	TutorialPlayState(void);
	TutorialPlayState(const TutorialPlayState&);
	TutorialPlayState& operator=(const TutorialPlayState&);
	~TutorialPlayState(void);

	// Asset IDs
	int	BGMID;
	int FontID;
	int CursorID;
	int tileBmpID;
	int declineID;
	int acceptID;
	int errorID;
	int moveID;
	int BackgroundID;
	int PanelID;
	int selectID;
	int rhurtID;
	int whurtID;
	int khurtID;
	int ahurtID;
	int	TennisballID;
	int PlungerID;
	int fireCrackerID;
	int WaterBalloonID;
	int boltID;
	int fireID;
	int waterID;
	int boingID;
	int thudID;
	int swingID;
	int throwID;
	int splashID;
	int crackerID;
	int tennisID;
	bool Throw;
	bool SpellHit;
	bool playVoice;
	bool fbHurt;
	int FadeImg;
	int Explosion;
	RECT fadeWindow;
	float checktimer;

	// For doing stuff
	bool Paused;
	bool Resume;
	bool Movement;
	bool Command;
	bool ItemMenu;
	bool StatsMenu;
	int CmndChoice;
	int ItemChoice;
	int MenuChoice;
	bool Attack;
	bool gameWon;
	float gameWonTimer;
	int currentMsg;
	bool convo;
	int abilitySelection;
	bool abilityTargeting;
	bool abilityMenu;
	// What part of the tutorial are we currently at?
	bool tutMove;
	bool tutAttack;
	bool tutItem;
	bool tutWeather;
	bool tutTiles;
	bool tutCharExplain;
	bool tutSpawnPoint;
	bool tutSpecialWin;
	bool tutControls;
	bool tutAbility;
	bool tutMenu;
	bool DiceShown;
	bool DiceRolled;
	float DShownTime;
	float DiceTime1;
	float DiceTime2;
	RECT diceRECT;
	bool SelectingaTile;
	int SelectingCount;
	int SizeOfParty;

	// variables for pre battle character selection
	int preLeftSelection;
	int preRightSelection;
	bool prebattle;
	vector<BaseCharacter*> selectFrom;
	vector<BaseCharacter*> selected;
	bool leftSideSelecting;

	// arcade input bools
	bool arcadeEnter;
	bool arcadeEscape;
	bool arcadeUp;
	bool arcadeDown;
	bool arcadeLeft;
	bool arcadeRight;
	bool arcadeBackspace;
	bool arcadeShift;
	bool arcadePlus;
	bool arcadeMinus;
	bool arcadeP;

	//DiceRoll Vectors
	vector<int> AtkRolls;
	vector<int> DefRolls;
	vector<int> EvadeRolls;
	vector<int> ARolls;
	vector<int> DRolls;
	vector<int> DiceImages;


	// Temporary stats for level-up screen display purposes
	int tempAtk;
	int tempStm;
	int tempDef;
	int tempAgi;
	int tempSpd;
	int tempHP;
	int tempMP;
	unsigned int tempLvl;

	char** tutorConvo;

	// Message System
	MessagingSystem* MS;

	// Bitmap Font
	CBitmapFont Font;

	// Character Stuff
	vector<BaseCharacter*> Characters;
	vector<Item*> Inventory;
	int HPotions;
	int MPotions;
	int Inhalers;
	BaseCharacter* Viewing;
	vector<BaseCharacter*> CharactersToTake;

	int AtkTypeStorage;
	float Shotspeed;
	float Shotspeed2;
	RECT FadeWindow;
	int FadeWindowImg;
	BaseCharacter* CurAttacker;
	BaseCharacter* CurDefender;
	float Modifier;

	// vector of strings to display
	vector<string>tutConvo;

	// particle strings
	vector<string> keys;
	vector<string> AllKeys;
	vector<string> ActiveKeys;

	// tile manager
	TileManager * gameGrid;
	Tile * activeTile;

	// SINGLETON
	static TutorialPlayState* pInstance;

	// Animation Manager
	AnimationManager* myManager;

	// Weather System
	WeatherSystem* WS;

	// position of cursor (in tile index space)
	int cursorX;
	int cursorY;
	
public:
	static TutorialPlayState* GetInstance(void);
	void DeleteInstance(void);

	// Inherited Functionality
	void Enter(void);	
	bool Input(void);	
	void Update(float fElapsedTime);	
	void Render(void);	
	void Exit(void);
	void Reset(void);
	//Attack/Defend Roll
	int DiceRoll(BaseCharacter* Attacker, BaseCharacter* Defender, int wizardEnum = -1);
	void RenderDice();
	void RenderRoll();
	RECT DiceCell(int X, int Y);

	void BattleWindowFade(void);
	void BattleWindow();

	// Message Procedure
	static void MessageProc(BaseMessage* pMsg);

	//Getting Damage for Rendering
	int TotalDamage;
	
	int GetDamage(void)				{ return TotalDamage; }
	void SetDamage(int totaldamage) { TotalDamage = totaldamage; }

	// Load tutorial instructional conversation
	bool LoadFile(void);

	int GetCursorX()
	{
		return cursorX;
	}

	int GetCursorY()
	{
		return cursorY;
	}

	void ArcadeInput();
	bool CheckMoveToTile(Tile* curTile, Tile* tar, vector<Tile*>* v = nullptr);
	void HighlightAction(bool enemy,int range);
	void HighlightMove();

};

